VAR as integer foldRollRight_Amt = 0, foldRollLeft_Amt = 0, foldRollDown_Amt = 0, foldRollUp_Amt = 0
VAR Demo$
  

'📚📚📚 PutString Library

  FUNCTION xAdj%(xi%)
  '        ⎺⎺⎺⎺⎺
      xAdj% = 0
      IF foldRollRight_Amt > 0 AND foldRollRight_Amt < 8 AND xi% <= foldRollRight_Amt THEN xAdj% = foldRollRight_Amt - xi%
      IF foldRollLeft_Amt > 0 AND foldRollLeft_Amt < 8 AND xi% > 7 - foldRollLeft_Amt THEN xAdj% = (7-foldRollLeft_Amt) - xi%
	END FUNCTION
  
  FUNCTION yAdj%(yi%)
  '        ⎺⎺⎺⎺⎺
      yAdj% = 0
      IF foldRollDown_Amt > 0 AND foldRollDown_Amt < 8 AND yi% <= foldRollDown_Amt THEN yAdj% = foldRollDown_Amt - yi%
      IF foldRollUp_Amt > 0 AND foldRollUp_Amt < 8 AND yi% > 7 - foldRollUp_Amt THEN yAdj% = (7-foldRollUp_Amt) - yi%
	END FUNCTION

  SUB PutString(s$, x%, y%)
  '   ⎺⎺⎺⎺⎺⎺⎺⎺⎺
      for c = 1 to len(s$)
        sc$ = MID$(s$, c, 1)
        this$ = _GETCHR$(ASC(sc$))
        for yi = 0 to 7
          for xi = 0 to 7
            IF MID$(this$, (xi + yi*8) + 1, 1) = "X" THEN PSET (x% + xi + (c-1)*8 + xAdj%(xi), y% + yi +yAdj%(yi))
          next xi
        next yi
      next c
  END SUB


'🟠🟠🟠 MAIN PROGRAM

  screen _newimage(132, 40, 14)

  ➔again:
    GOSUB â—ˆDemoRollâž¡
    GOSUB ◈DemoRoll⬅
    GOSUB ◈DemoRoll➡⬅
    GOSUB ◈DemoRoll⬇
    GOSUB ◈DemoRoll⬆
    GOSUB ◈DemoRoll⬇⬆
    GOSUB ◈DemoRoll➡⬅⬇⬆
    GOSUB ◈DemoRoll➡⬇
  goto ➔again

  END

'🟠🟠🟠 GOSUB ROUTINES

  â—ˆDemoRollâž¡:
      Demo$ = "Roll Right"
      for f = 0 to 7 step 1
        foldRollRight_Amt = f
        GOSUB â—ˆHelloWorld
      next f
      for f = 7 to 0 step -1
        foldRollRight_Amt = f
        GOSUB â—ˆHelloWorld
      next f
   RETURN

  ◈DemoRoll⬅:
      Demo$ = "Roll Left"
      for f = 0 to 7 step 1
        foldRollLeft_Amt = f
        GOSUB â—ˆHelloWorld
      next f
      for f = 7 to 0 step -1
        foldRollLeft_Amt = f
        GOSUB â—ˆHelloWorld
      next f
   RETURN

  ◈DemoRoll➡⬅:
      Demo$ = "Roll In L+R"
      for f = 0 to 3 step 1
        foldRollRight_Amt = f : foldRollLeft_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
      for f = 3 to 0 step -1
        foldRollRight_Amt = f : foldRollLeft_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
   RETURN

  ◈DemoRoll⬇:
      Demo$ = "Roll Down"
      for f = 0 to 7 step 1
        foldRollDown_Amt = f
        GOSUB â—ˆHelloWorld
      next f
      for f = 7 to 0 step -1
        foldRollDown_Amt = f
        GOSUB â—ˆHelloWorld
      next f
   RETURN

  ◈DemoRoll⬆:
      Demo$ = "Roll Up"
      for f = 0 to 7 step 1
        foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld
      next f
      for f = 7 to 0 step -1
        foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld
      next f
   RETURN

  ◈DemoRoll⬇⬆:
      Demo$ = "Roll In D+U"
      for f = 0 to 3 step 1
        foldRollDown_Amt = f : foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
      for f = 3 to 0 step -1
        foldRollDown_Amt = f : foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
   RETURN

  ◈DemoRoll➡⬅⬇⬆:
      Demo$ = "Roll In All"
      for f = 0 to 3 step 1
        foldRollRight_Amt = f : foldRollLeft_Amt = f : foldRollDown_Amt = f : foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
      for f = 3 to 0 step -1
        foldRollRight_Amt = f : foldRollLeft_Amt = f : foldRollDown_Amt = f : foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
      Demo$ = "Roll To Corners"
      for f = 0 to 7 step 1
        foldRollRight_Amt = f : foldRollLeft_Amt = f : foldRollDown_Amt = f : foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
      for f = 7 to 0 step -1
        foldRollRight_Amt = f : foldRollLeft_Amt = f : foldRollDown_Amt = f : foldRollUp_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
   RETURN

  ◈DemoRoll➡⬇:
      Demo$ = "Roll R+D"
      for f = 0 to 7 step 1
        foldRollRight_Amt = f : foldRollDown_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
      for f = 7 to 0 step -1
        foldRollRight_Amt = f : foldRollDown_Amt = f
        GOSUB â—ˆHelloWorld : _delay 0.25
      next f
   RETURN

  â—ˆHelloWorld:
      CLS
      COLOR 38
      LOCATE 4,0 : PRINT Demo$;
      COLOR 54
      PutString("H", 3, 3)
      PutString("E", 11, 4)
      PutString("L", 19, 5)
      PutString("L", 27, 6)
      PutString("O", 35, 7)
      PutString("W", 51, 8)
      PutString("O", 59, 7)
      PutString("R", 67, 6)
      PutString("L", 75, 5)
      PutString("D", 83, 4)
      PutString("!", 91, 3)
  	  _DELAY 0.5
  RETURN